package com.wallet.crypto.trustapp.di;

import android.content.Context;

import com.google.gson.Gson;
import com.wallet.crypto.trustapp.App;
import com.wallet.crypto.trustapp.repository.PasswordStore;
import com.wallet.crypto.trustapp.repository.TrustPasswordStore;
import com.wallet.crypto.trustapp.util.LogInterceptor;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;

@Module
class ToolsModule {
	@Provides
	Context provideContext(App application) {
		Context applicationContext = application.getApplicationContext();
		return applicationContext;
	}

	@Singleton
	@Provides
	Gson provideGson() {
		Gson gson = new Gson();
		return gson;
	}

	@Singleton
	@Provides
	OkHttpClient okHttpClient() {
		OkHttpClient build = new OkHttpClient.Builder()
				.addInterceptor(new LogInterceptor())//添加拦截器,打印日志
				.build();
		return build;
	}

	@Singleton
	@Provides
	PasswordStore passwordStore(Context context) {
		TrustPasswordStore trustPasswordStore = new TrustPasswordStore(context);
		return trustPasswordStore;
	}
}
